﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArticleEdit.aspx.cs" Inherits="FxhjpgWeb.WebSite.WebAdmin.ArticleEdit" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="FxhjpgWeb.Model" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>文章管理</title>
    <link href="/css/admin/admin.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="/js/jquery.js"></script>    
    <script type="text/javascript" src="/js/admin/admin.js"></script>
    <!--kindEditor配置Begin-->
    <link rel="stylesheet" href="/js/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="/js/kindeditor/plugins/code/prettify.css" />
    <script type="text/javascript" charset="utf-8" src="/js/kindeditor/kindeditor-min.js?v=4.1.7"></script>
    <script type="text/javascript" charset="utf-8" src="/js/kindeditor/lang/zh_CN.js?v=4.1.7"></script>
    <script type="text/javascript" charset="utf-8" src="/js/kindeditor/plugins/code/prettify.js?v=4.1.7"></script>
    <script type="text/javascript">
        //此编辑器初始化参数请参考http://www.kindsoft.net/docs/option.html
        var editor, editor_en;
        KindEditor.ready(function (K) {
            editor = K.create('#content', {
                cssPath: '/js/kindeditor/plugins/code/prettify.css',
                filterMode: false,
                urlType: 'absolute',
                uploadJson: 'ajax/upload_json.ashx?width=600&height=520'   //指定上传文件的服务器端程序
                //fileManagerJson: 'Ajax/file_manager_json.ashx',     //指定浏览远程图片的服务器端程序
                //allowFileManager: false
            });
            editor_en = K.create('#content_en', {
                cssPath: '/js/kindeditor/plugins/code/prettify.css',
                filterMode: false,
                urlType: 'absolute',
                uploadJson: 'ajax/upload_json.ashx?width=600&height=520'   //指定上传文件的服务器端程序
                //fileManagerJson: 'Ajax/file_manager_json.ashx',     //指定浏览远程图片的服务器端程序
                //allowFileManager: false
            });
            prettyPrint();
        });
    </script>
    <!--kindEditor配置End-->
    <!--uploadify配置Begin-->
    <link rel="stylesheet" href="/js/uploadify/uploadify.css" />
    <script type="text/javascript" charset="utf-8" src="/js/uploadify/jquery.uploadify.js"></script>
	<script type="text/javascript">
	    $(function () {
	        $('#file_upload').uploadify({
	            'formData': {
	                'cid': '<%=id %>'
	            },
	            'buttonText': '上传封面图片',
	            'queueSizeLimit': 1,
	            'swf': '/js/uploadify/uploadify.swf',
	            'uploader': 'Ajax/uploadify.ashx?t=2',
	            'onUploadSuccess': function (file, data, response) {
	                var obj = $.parseJSON(data);
	                if (obj.error == 0) {
	                    $("#faceImg").val(obj.url);
	                }
	            }
	        });
	    });
	</script>
    <!--uploadify配置End-->
</head>
<body>
    <div class="titlebt"><%= id > 0 ? "修改文章" : "新建文章"%></div>
    <!--显示列表-->
    <div id="all">
        <div class="k_all3">
            <form id="form1" action="" method="post" onsubmit="return checkdata();">
            <table width="100%" cellpadding="0" cellspacing="0" id="bk">
                <tbody>
                    <tr>
                        <td width="100" height="35" align="right">
                            <span class="red">*</span>文章分类：
                        </td>
                        <td width="990">
                            <select id="cateid" name="cateid" data-val="true" data-val-required="*请选择文章分类！">
                                <option value="">请选择分类</option>
                                <% 
                                    foreach (NewsClass item in newsClassList)
                                    { 
                                %>
                                <option value='<%=item.Id %>' <%if(newsInfo.CId==item.Id) {%> selected="selected"<%} %>><%=item.Name%></option>
                                <%
                                    }
                                %>
                            </select>
                            <span class="field-validation-valid" data-valmsg-for="cateid" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            <span class="red">*</span>文章名称：
                        </td>
                        <td width="990">
                            <input type="text" id="title" name="title" value="<%=newsInfo.Title %>" style="width:350px" data-val="true" data-val-required="*请填写文章名称！"/>
                            <span class="field-validation-valid" data-valmsg-for="title" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            文章英文名称：
                        </td>
                        <td width="990">
                            <input type="text" id="title_en" name="title_en" value="<%=newsInfo.Title_En %>" style="width:350px"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            <span class="red">*</span>关键字：
                        </td>
                        <td width="990">
                            <input type="text" id="keyWord" name="keyWord" value="<%=newsInfo.Keyword %>"  style="width:250px" data-val="true" data-val-required="*请填写关键字！"/>
                            <span class="field-validation-valid" data-valmsg-for="keyWord" data-valmsg-replace="true"></span>多个关键字用英文输入法","分开
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            封面图片：
                        </td>
                        <td width="990">
                            <span>提示：若内容里有图片，请在这里设置封面，来标识此文章是带图片的<br />
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;可以直接复制图片地址到这里<br /></span>
		                    <input id="faceImg" name="faceImg" type="text" value="<%=newsInfo.Pic %>" style="width:350px">
                            <div>   
                                <input id="file_upload" name="file_upload" type="file" multiple="true"/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            <span class="red">*</span>新闻内容：
                        </td>
                        <td width="990">
                            <span id="field-content" class="field-validation-error" style="display:none">*请填写新闻内容！</span>
                            <textarea id="content" name="content" style="width: 90%; height: 350px;"><%=newsInfo.Content%></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="35" align="right">
                            新闻英文内容：
                        </td>
                        <td width="990">
                            <textarea id="content_en" name="content_en" style="width: 90%; height: 350px;"><%=newsInfo.Content_En%></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" height="35">
                            <div class="pl200">
                                <input type="hidden" name="sourceurl" value="<%=Request.UrlReferrer.AbsoluteUri %>" />
                                <input type="submit" class="butt_tle" style="width: 50px" value="确定" />
                                <input type="button" class="butt_tle" style="width: 80px" value="返回列表" onclick='location.href="<%=FxhjpgWeb.WebSite.Code.Utility.GetUrlReferrer(Request, "ArticleList.aspx", "ArticleEdit.aspx") %>"'/>
                                <%--<input type="button" class="butt_tle" style="width: 50px" value="预览" onclick="yulan();" />--%>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        function checkdata() {
            if (editor.text() == "") {
                $("#field-content").show();
                return false;
            }
            return true;
        }
        function yulan() {
            var obj = window.open("about:blank");
            var html = '<html><head><link href="/css/_common.css" type="text/css" rel="stylesheet" /></head><body><div class="mainb"><div class="job01 ft_st">';
            html += '<h2 class="t_center pb10 f18">' + $("#title").val() + '</h2>';
            html += '<div style="text-align:right">作者:<%=User.Identity.Name%> 添加时间:<%=DateTime.Now.ToString()%></div><br/>';
            html += '<div style="">';
            html += editor.html();
            html += "</div></div></div></html></html>";
            obj.document.write(html);
        }
    </script>
</body>
</html>